import App from './App';
import uView from '@/uni_modules/uview-ui';

// #ifndef VUE3
import Vue from 'vue';
Vue.config.productionTip = false;

Vue.use(uView);

// 注册全局登录拦截组件
//import '@/components/LoginInterceptor.js';

Vue.prototype.isLogin = function() {
	const token = uni.getStorageSync('token');
	console.log('全局函数token:' + token);
	if(token && token.length > 0) {
		return true;
	}
	return false;	
}
Vue.prototype.goPage = function(url) {
	console.log(url)
	uni.navigateTo({
		url
	})
}
Vue.prototype.toast = function(message) {
	uni.showToast({
		icon: 'none',
		title: message
	});	
}

Vue.prototype.loading = function() {
	
}

App.mpType = 'app';
const app = new Vue({
    ...App
});
app.$mount();
// #endif

//Vue.prototype.xAudioContext = uni.createInnerAudioContext();
//Vue.prototype.xAudioContext.autoplay = false;
/*
Vue.prototype.xAudioPlay = function(src, onstop) {
	console.log("play =========");
	if(Vue.prototype.xAudioContext == null) {
		Vue.prototype.xAudioContext = uni.createInnerAudioContext();
		Vue.prototype.xAudioContext.autoplay = false;
	}
	
	if(Vue.prototype.xAudioIsPlay) {
		console.log('aaaaaaaaaaaa');
		Vue.prototype.xAudioIsPlay = false;
		onstop();
		Vue.prototype.xAudioContext.stop();
	}
	
	Vue.prototype.xAudioContext.src = src;
	Vue.prototype.xAudioIsPlay = true;
	Vue.prototype.xAudioContext.play();
};

Vue.prototype.xAudioStop = function() {
	console.log("stop =========");
	if(Vue.prototype.xAudioContext != null) {
		Vue.prototype.xAudioIsPlay = false;
		Vue.prototype.xAudioContext.stop();
	}
}
*/

// #ifdef VUE3
import { createSSRApp } from 'vue';
export function createApp() {
  const app = createSSRApp(App);
  return {
    app
  }
}
// #endif